package ch9;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;
import java.io.PrintWriter;

@WebFilter(filterName = "MyFilter",urlPatterns = "/Myservlet")
public class MyFilter implements Filter {
    public void destroy() {
        //过滤器对象在销毁时自动调用，释放资源
    }

    public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws ServletException, IOException {
//        chain.doFilter(req, resp);
        PrintWriter out = resp.getWriter();
        out.write("Hello Filter");
    }

    public void init(FilterConfig config) throws ServletException {
    //配置初始化参数
    }

}
